Logical block address remapping

ABSTRACT

A method and system is disclosed that remaps logical block addresses (LBAs) for defragmentation that is managed at the storage device level. The remapping may include sequentially remapping LBAs where individual files are remapped so that each file is referenced by sequential LBAs. The remapping of LBAs may be performed without changes to the physical location of data.

TECHNICAL FIELD

This application relates generally to memory devices. More specifically,this application relates to sequentially remapping logical blockaddresses in reprogrammable non-volatile semiconductor flash memory.

BACKGROUND

Non-volatile memory systems, such as flash memory, have been widelyadopted for use in consumer products. Flash memory may be found indifferent forms, for example in the form of a portable memory card thatcan be carried between host devices or as a solid state disk (SSD)embedded in a host device. When writing data to a conventional flashmemory system, a host typically writes data to, and reads data from,addresses within a logical address space of the memory system. Thememory system then commonly maps data between the logical address space(e.g. a logical block address (LBA)) and the physical blocks ormetablocks of the memory, where data is stored in fixed logical groupscorresponding to ranges in the logical address space. The host keepstrack of the LBAs of its data files within the logical address space andthe memory system may operate without knowledge of this mapping.

A drawback of memory systems that operate in a logical address space isfragmentation. Data written by a host file system may often befragmented in logical address space, where many fixed logical groups areonly partially updated with new data. The fragmentation may occur as aresult of cumulative fragmentation of free space by the host filesystem, and possibly even as a result of inherent fragmentation ofindividual files by the host file system. When a memory device is fullyfragmented, in order to improve performance the host may need to performdisk defragmentation in which the host reads the disk and re-writes eachfile in a sequential manner. The performance of a memory system may bedegraded by increased fragmentation and frequent disk defragmentation.Disk defragmentation may be a long process that results in flash wearout and requires significant time/resources. Accordingly, hosts mayrefrain from performing defragmentation to avoid poor performance.Software solutions to more efficient defragmentation may occur at thefile system level when a user schedules a time which the defragmentationsoftware would run.

SUMMARY

Defragmentation that is managed at the storage device level may be moreefficient and require fewer resources than software solutions at thefile system level. The device performs a remap, which may be a fasteroperation than the host reading and re-writing the data as part of afull defragmentation. The remapping may include sequentially remappinglogical block addresses (LBAs). Individual files may be remapped so thateach file is referenced by sequential LBAs. The remapping of LBAs may beperformed without changes to the physical location of data.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of a host connected with a memory systemhaving non-volatile memory.

FIG. 2 is a block diagram of an exemplary flash memory system controllerfor use in the system of FIG. 1.

FIG. 3 illustrates an example physical memory organization of the systemof FIG. 1.

FIG. 4 shows an expanded view of a portion of the physical memory ofFIG. 3.

FIG. 5 is an illustration of remapping logical block addresses.

FIG. 6 is a flow chart illustrating a remapping process.

DESCRIPTION OF THE PRESENTLY PREFERRED EMBODIMENTS

A flash memory system suitable for use in implementing aspects of theinvention is shown in FIGS. 1-2. A host system 100 of FIG. 1 stores datainto and retrieves data from a flash memory 102. The flash memory may beembedded within the host, such as in the form of a solid state disk(SSD) drive installed in a personal computer. Alternatively, the memory102 may be in the form of a flash memory card that is removablyconnected to the host through mating parts 104 and 106 of a mechanicaland electrical connector as illustrated in FIG. 1. A flash memoryconfigured for use as an internal or embedded SSD drive may look similarto the schematic of FIG. 1, with one difference being the location ofthe memory system 102 internal to the host. SSD drives may be in theform of discrete modules that are drop-in replacements for rotatingmagnetic disk drives.

Examples of commercially available removable flash memory cards includethe CompactFlash (CF), the MultiMediaCard (MMC), Secure Digital (SD),miniSD, Memory Stick, SmartMedia, TransFlash, and microSD cards.Although each of these cards may have a unique mechanical and/orelectrical interface according to its standardized specifications, theflash memory system included in each may be similar. These cards are allavailable from SanDisk Corporation, assignee of the present application.SanDisk also provides a line of flash drives under its Cruzer trademark,which are hand held memory systems in small packages that have aUniversal Serial Bus (USB) plug for connecting with a host by plugginginto the host's USB receptacle. Each of these memory cards and flashdrives includes controllers that interface with the host and controloperation of the flash memory within them.

Host systems that may use SSDs, memory cards and flash drives are manyand varied. They include personal computers (PCs), such as desktop orlaptop and other portable computers, tablet computers, cellulartelephones, smartphones, personal digital assistants (PDAs), digitalstill cameras, digital movie cameras, and portable media players. Forportable memory card applications, a host may include a built-inreceptacle for one or more types of memory cards or flash drives, or ahost may require adapters into which a memory card is plugged. Thememory system may include its own memory controller and drivers butthere may also be some memory-only systems that are instead controlledby software executed by the host to which the memory is connected. Insome memory systems containing the controller, especially those embeddedwithin a host, the memory, controller and drivers are often formed on asingle integrated circuit chip.

The host system 100 of FIG. 1 may be viewed as having two major parts,insofar as the memory 102 is concerned, made up of a combination ofcircuitry and software. They are an applications portion 108 and adriver portion 110 that interfaces with the memory 102. There may be acentral processing unit (CPU) 112 implemented in circuitry and a hostfile system 114 implemented in hardware. In a PC, for example, theapplications portion 108 may include a processor 112 running wordprocessing, graphics, control or other popular application software. Ina camera, cellular telephone or other host system 114 that is primarilydedicated to performing a single set of functions, the applicationsportion 108 includes the software that operates the camera to take andstore pictures, the cellular telephone to make and receive calls, andthe like.

The host system 100 may be referred to as a front end, while the flashmemory 116 may be referred to as a back end. The controller 118interfaces with both the front end (host 100) and the back end (memory116).

The memory system 102 of FIG. 1 may include non-volatile memory, such asflash memory 116, and a system controller 118 that both interfaces withthe host 100 to which the memory system 102 is connected for passingdata back and forth and controls the memory 116. The system controller118 may convert between logical addresses of data used by the host 100and physical addresses of the flash memory 116 during data programmingand reading. Functionally, the system controller 118 may include a frontend 122 that interfaces with the host system, controller logic 124 forcoordinating operation of the memory 116, and flash management logic 126for internal memory management operations. There may also be one or moreflash interface modules (FIMs) 128 or memory interfaces to provide acommunication interface between the controller with the flash memory116.

The system controller 118 may be implemented on a single integratedcircuit chip, such as an application specific integrated circuit (ASIC)such as shown in FIG. 2. The processor 206 of the system controller 118may be configured as a multi-thread processor capable of communicatingvia a memory interface 204 having I/O ports for each memory bank in theflash memory 116. The system controller 118 may include an internalclock 218. The processor 206 communicates with an error correction code(ECC) module 214, a RAM buffer 212, a host interface 216, and boot codeROM 210 via an internal data bus 202. The RAM 212 may be a staticrandom-access memory (“SRAM”) in which a compaction bitmap is stored.The bitmap may be generated and stored in SRAM and may be discardedafter it is used for transferring data from a source block to adestination block. The ROM 210 may be used to initialize a memory system102, such as a flash memory device. The memory system 102 that isinitialized may be referred to as a card. The host interface 216 mayprovide the data connection with the host.

FIG. 3 conceptually illustrates an organization of the flash memory cellarray 112 (FIG. 1). The flash memory cell array 112 may include multiplememory cell arrays which are each separately controlled by a single ormultiple memory controllers 114. Four planes or sub-arrays 302, 304,306, and 308 of memory cells may be on a single integrated memory cellchip, on two chips (two of the planes on each chip) or on four separatechips. The specific arrangement is not important to the discussionbelow. Other numbers of planes, such as 1, 2, 8, 16 or more may exist ina system. The planes are individually divided into groups of memorycells that may form the minimum unit of erase, hereinafter referred toas blocks. Blocks of memory cells are shown in FIG. 3 by rectangles,such as blocks 310, 312, 314, and 316, located in respective planes 302,304, 306, and 308. There can be any number of blocks in each plane. Asdiscussed below, the physical locations of the memory blocks may beidentified by a mapping, such as the logical to physical mapping andeach block may be identified by a logical block address (LBA).

As mentioned above, the block of memory cells is the unit of erase, thesmallest number of memory cells that are physically erasable together.For increased parallelism, however, the blocks are operated in largermetablock units. One block from each plane is logically linked togetherto form a metablock. The four blocks 310, 312, 314, and 316 are shown toform one metablock 318. All of the cells within a metablock may beerased together. The blocks used to form a metablock need not berestricted to the same relative locations within their respectiveplanes, as is shown in a second metablock 320 made up of blocks 322,324, 326, and 328. Although it is usually preferable to extend themetablocks across all of the planes, for high system performance, thememory system can be operated with the ability to dynamically formmetablocks of any or all of one, two or three blocks in differentplanes. This allows the size of the metablock to be more closely matchedwith the amount of data available for storage in one programmingoperation.

The individual blocks are in turn divided for operational purposes intopages of memory cells, as illustrated in FIG. 4. FIG. 4 shows anexpanded view of a portion of the physical memory of FIG. 3. The memorycells of each of the blocks 310, 312, 314, and 316, for example, areeach divided into eight pages P0-P7. Alternatively, there may be 16, 32or more pages of memory cells within each block. The page is the unit ofdata programming and reading within a block, containing the minimumamount of data that are programmed or read at one time. However, inorder to increase the memory system operational parallelism, such pageswithin two or more blocks may be logically linked into metapages. Ametapage 402 is illustrated in FIG. 4, being formed of one physical pagefrom each of the four blocks 310, 312, 314, and 316. The metapage 402,for example, includes the page P2 in each of the four blocks but thepages of a metapage need not necessarily have the same relative positionwithin each of the blocks. The mapping including the LBAs may refer tometapages.

Instead of reading data out of the storage device and writing itsequentially in a new location (LBA), the host may use the remappingdescribed herein. This remapping may be provided by the storage device.The host sends a list of LBA pairs (Current LBA, New LBA) through thestorage device. The LBA pair may identify a particular LBA (Current LBA)and the LBA that it is remapped to (New LBA). The LBA pair may furtheridentify a range of blocks that are remapped (Range of current LBA,Range of new LBA). In other words, the “pair” may be more than just apair of blocks when it identifies the current and new mapping for morethan one block. The memory device re-maps the current LBA to the new LBAwithout actually copying the data or changing the physical location ofthat data.

In a back end system which maps a physical block to severaldiscontinuous LBA addresses and performs optimizations over this table,remapping may be an efficient process that does not require significantprocessing. Full defragmentation may result in sequential or continuousLBA addresses, but it also requires changes to the physical locations ofthe data. In full defragmentation (in which the host reads all data andrewrites that data) the data is stored sequentially in the physicalmemory. The remapping changes the LBA table, so that individual fileshave sequential or continuous LBA addresses for each file. However, theremapping does not result in the data being stored sequentially in thephysical memory. FIG. 5 illustrates the differences between theremapping and a full defragmentation.

FIG. 5 is an illustration of remapping logical block addresses. FIG. 5illustrates the remapping of four physical blocks in a fragmented state506. The blocks in the fragmented state 506 store data from two files:File A 502 and File B 504. Each of the four physical blocks includes amix of data from File A and File B. For example, physical block 1includes LBA 11 and LBA 17 from File A and includes LBA 18 and LBA 10from File B.

A full defragmentation is illustrated in the full defragmentation state508. As shown with the full defragmentation state 508, the two files arenot only remapped so that the LBAs for each file are sequential, but thephysical locations of the data are copied so that the physical storageof the blocks is sequential. Accordingly, the full defragmentation state508 illustrates File A being stored as LBA 10-14 in Physical Blocks 1-2and File B being stored as LBA 15-25 in Physical Blocks 3-5. This fulldefragmentation may require significant time and resources to read andre-write all the blocks to sequential physical blocks.

The remapping is illustrated in the remapping state 510 and may bereferred to as remap defragmentation. The remapping state 510 remaps theLBAs so that the LBAs for individual files are sequential withoutchanging the physical locations. Accordingly, the remapping state 510 isidentical to the fragmented state except the LBAs have been remapped. Inparticular, File A is remapped to LBA 10-14, while File B is remapped toLBA 15-25. In alternative embodiments, the range of the LBAs for theFiles may be different (for example starting at LBA 01), but should besequential. The LBAs between different files does not need to becontinuous as long as the LBAs for each file are sequential. In otherwords, File B could be remapped to LBA 16-26 (rather than LBA 15-25) orany other range that does not overlap with already used LBAs as long asFile B is remapped to sequential LBAs.

The remapping shown in FIG. 5 may be generated based on LBA pairs thatmap from a current LBA to a new LBA. The remapping may be developed bythe host and implemented by the storage device. In other words, the hostmay select the LBA pairs. For the example in FIG. 5 the LBA remappingfor File A is shown in Table 1:

TABLE 1 Remapping Pairs For File A Current LBA New LBA 11 10 17 12 12 1116 18 14 16 50 13

Table 2 illustrates the remapping of File B:

TABLE 2 Remapping Pairs For File B Current LBA New LBA 18 19 10 15 16 1834 16 15 17 19 20 24 23 33 25 26 24

The generation of the remapping pairs is used to remap a fragmented fileinto a continuous and sequential LBAs for all blocks in the file. Asdescribed, the logical addresses are remapped while the physicallocation of the blocks is not changed. The blocks may remain fragmentedin the physical memory after remapping, but the logical addresses (LBAs)are not fragmented and are sequential for each file.

FIG. 6 is a flow chart illustrating a remapping process. In particular,FIG. 6 further illustrates the remapping operation described withrespect to FIG. 5. In block 602, files are identified including thememory blocks or data that make up that file. In block 604, a list ofthose memory blocks is retrieved and includes all the LBAs that map tothe physical location of the blocks/data that make up the file. In block606, the files and their blocks/data is analyzed to identifydefragmentation of the logical address space for each file. Based onthis analysis, an LBA pair is generated for each block to be remapped asin block 608. In particular, in order to remap a particular file intocontinuous/sequential logical addresses, some of the old LBAs may beremapped into new LBAs. The LBA pair may merely be (Old LBA, New LBA)for each block or other unit of data that is to be remapped. In block610, the old LBAs are remapped so that each file has sequential LBAswithout changing the physical location for the blocks.

In block 612, another operation may be performed on the remapped data,such as garbage collection. Garbage collection is merely one example, ofan operation that is improved because the blocks for each file arelogically addressed sequentially. In particular, sequential logicaladdresses may improve the speed of garbage collection operations. Inparticular, the sequential logical addresses may allow the file to beaccessed in a single read command (i.e. sequential read) rather thanmultiple reads if the logical addresses for a file were not continuousor sequential. The garbage collection operation will require feweroperations and commands (e.g. fewer reads) when the files are sequentialaddressed in the logical space. In particular, if a file is sequentialon the LBA side, the garbage collection could make it sequential on thephysical side. Accordingly, the remapping followed by garbage collectionmay result in the file being sequential on the logical side of the LBAaddress and on the physical side of the flash blocks. The garbagecollection may be performed as a background operation after theremapping.

The remapping may improve a number of times that the device performsgarbage collection. The device may eventually (through backgroundoperations) update the physical blocks of data to the LBA so that thefiles may be sequential at the physical level. It may also increase thewrite command performance since the data would be placed in a completephysical block. In addition, the host may not have to issue many read orwrite commands to access a single file, and it may be able to use asingle command. In addition, the amount of blocks which are partiallyprogrammed may be minimized which may help flash management by reducingthe size of the management tables and seek times. In addition, the“write amplification factor” which is the amount of data a flashcontroller has to write in relation to the amount of data that the hostcontroller wants to write (due to any internal copying of data from oneblock to another block) would decrease.

In one embodiment, the device may inform the host of a minimumgranularity for the remapping process described herein. The minimumgranularity may be the smallest size of data for which the remap processis triggered. For example, each LBA may be a byte or sector (e.g. 512bytes or 4 kilobytes), and the remap may be set for a minimum number ofLBAs, such as ten sectors, in one example. The host may not do a remapfor each sector, and may remap only for the minimum amount of sectors.This may reduce the number of LBAs in the logical to physical table.This minimum size or minimum granularity may be part of an existingcommand or may be a new command by the device to the host.

In alternative embodiments, only the host may know about files and theidentification. There may be an indication of files that is then used bythe device for separating files into physical blocks. The device mayreorder LBAs based on a sequence without knowledge of the files, but thefile indication may be used for storing in physical blocks. Adefragmentation process may occur whenever a file is deleted. Thedeletion of a file may trigger the host to defragment the files. Thisdefragmentation may result in all files being contiguously stored.Likewise, there may be other triggers for defragmentation.

A “computer-readable medium,” “machine readable medium,”“propagated-signal” medium, and/or “signal-bearing medium” may compriseany device that includes, stores, communicates, propagates, ortransports software for use by or in connection with an instructionexecutable system, apparatus, or device. The machine-readable medium mayselectively be, but not limited to, an electronic, magnetic, optical,electromagnetic, infrared, or semiconductor system, apparatus, device,or propagation medium. A non-exhaustive list of examples of amachine-readable medium would include: an electrical connection“electronic” having one or more wires, a portable magnetic or opticaldisk, a volatile memory such as a Random Access Memory “RAM”, aRead-Only Memory “ROM”, an Erasable Programmable Read-Only Memory (EPROMor Flash memory), or an optical fiber. A machine-readable medium mayalso include a tangible medium upon which software is printed, as thesoftware may be electronically stored as an image or in another format(e.g., through an optical scan), then compiled, and/or interpreted orotherwise processed. The processed medium may then be stored in acomputer and/or machine memory.

In an alternative embodiment, dedicated hardware implementations, suchas application specific integrated circuits, programmable logic arraysand other hardware devices, can be constructed to implement one or moreof the methods described herein. Applications that may include theapparatus and systems of various embodiments can broadly include avariety of electronic and computer systems. One or more embodimentsdescribed herein may implement functions using two or more specificinterconnected hardware modules or devices with related control and datasignals that can be communicated between and through the modules, or asportions of an application-specific integrated circuit. Accordingly, thepresent system encompasses software, firmware, and hardwareimplementations.

The illustrations of the embodiments described herein are intended toprovide a general understanding of the structure of the variousembodiments. The illustrations are not intended to serve as a completedescription of all of the elements and features of apparatus and systemsthat utilize the structures or methods described herein. Many otherembodiments may be apparent to those of skill in the art upon reviewingthe disclosure. Other embodiments may be utilized and derived from thedisclosure, such that structural and logical substitutions and changesmay be made without departing from the scope of the disclosure.Additionally, the illustrations are merely representational and may notbe drawn to scale. Certain proportions within the illustrations may beexaggerated, while other proportions may be minimized. Accordingly, thedisclosure and the figures are to be regarded as illustrative ratherthan restrictive.

We claim:
 1. A method for remapping comprising: in a memory systemhaving the blocks stored in non-volatile storage and a controller incommunication with the non-volatile storage, the controller isconfigured for: receiving an indication of a minimum size of data storedin fragmented blocks that each have a logical block address (LBA); andreceiving, based on the minimum size, a remapping of the LBA for each ofthe blocks so the LBAs for different files are sequential, while thephysical addresses are unchanged.
 2. The method of claim 1 wherein thereceiving by the controller is from a host.
 3. The method of claim 2wherein the remapping from the host is by generating an LBA pair foreach of the LBAs to be remapped, wherein the LBA comprises the currentLBA to be remapped and a new LBA that the current LBA is mapped to. 4.The method of claim 1 wherein the receiving the indication is fromanother module in the memory system which is responsible for managingthe file system.
 5. The method of claim 4 wherein the memory system canpower-up after remapping so that a host can read a new updated logicalto physical address table based on the remapping.
 6. The method of claim1 wherein the memory comprising non-volatile storage includes a flashmemory or a solid state memory.
 7. The method of claim 1 furthercomprising: performing a garbage collection operation after theremapping, wherein the garbage collection read commands are minimizedbecause each of the files includes sequential LBAs.
 8. The method ofclaim 7 wherein the garbage collection operation physically aggregatesdata on physical blocks according to the sequential LBAs from theremapping.
 9. The method of claim 1 further comprising: receiving acommand from a host to perform physical aggregation of data on physicalblocks according to the sequential LBAs from the remapping.
 10. A memorysystem comprising: a non-volatile storage having an array of memoryblocks storing data that is associated with logical block addresses(LBAs); and a controller in communication with the blocks, thecontroller configured to: receive an indication of fragmented data thatcomprises one or more files, wherein the one or more files are stored inthe memory blocks and are fragmented based on their LBAs, furtherwherein the indication includes a minimum size of the fragmented datathat each have an LBA; and remapping, in response to the indication andbased on the minimum size, the LBAs for each of the one or more filessuch that each of the one or more files is identified by LBAs that aresequential; wherein the received indication comprises a listing of LBApairs that provides a new LBA for each current LBA.
 11. The memorysystem of claim 10 wherein the indication of the one or more files isprovided by a host and the host identifies the one or more files ratherthan the controller.
 12. The memory system of claim 10 wherein the LBApairs comprises one or more blocks, further wherein the LBA pairs caninclude a range of blocks.
 13. The memory system of claim 10 wherein thefragmented data comprises non-sequential LBAs for each of the one ormore files.
 14. The memory system of claim 10 wherein the LBA identifiesa physical block.
 15. The memory system of claim 14 wherein locations ofeach of the physical blocks is unchanged after the remapping.
 16. Thememory system of claim 10 wherein the remapping generates a new copy oflogical to physical table, further wherein an old copy of the logical tophysical table is stored in case of a power failure during an update.17. A method for operating a memory system comprising: in a non-volatilestorage device having a controller and blocks of memory, the controlleris configured for: receiving a list of logical block address pairs forremapping logical block addresses for files, wherein each of the filescomprises data referenced by the logical block addresses; and remappingthe logical block addresses based on the list of logical block addresspairs without changing a physical location of the data referenced by thelogical block addresses, wherein the remapping changes the logical blockaddresses to be sequential for each of the files.
 18. The method ofclaim 17 wherein the remapping changes the logical block addresses tocombine each file into the same blocks.
 19. The method of claim 17wherein the list of pairs is received from a host.
 20. The method ofclaim 19 wherein the list of pairs includes a range of values that areremapped.
 21. The method of claim 17 wherein the list of logical blockaddress pairs comprises an original logical block address and a newlogical block address.
 22. The method of claim 21 wherein the remappingcomprises remapping the original logical block address of data to thenew logical block address.
 23. The method of claim 17 wherein theremapping occurs after each of the files are deleted.